package com.ghpt.controller;
import com.ghpt.pojo.DianChi;
import com.ghpt.service.DianChiService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;

@RestController
@RequestMapping("/dianchi")
public class DianChiController {
    private final DianChiService dianChiService;

    public DianChiController(DianChiService dianChiService) {
        this.dianChiService = dianChiService;
    }
    @GetMapping("/{id}")
    public DianChi getDianChiById(@PathVariable Long id) {
        System.out.println("结果是"+dianChiService.findDianChiById(id));
        return dianChiService.findDianChiById(id);
    }
    @PutMapping
    public int updateDianChi(@RequestBody DianChi dianChi) {
        return dianChiService.updateById(dianChi);
    }
}
